﻿@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<script src="~/Template/ace_admin_v1.4.0/components/_mod/fuelux/tree.js"></script>
<div class="row" id="app">
    <div class="col-xs-12">
        <!--科室-->
        <div class="row" id="keshidiv">
            <div class="col-xs-12">
                <!--搜索-->
                <div class="row">
                    <div class="col-xs-12 col-sm-8">
                        <div class="input-group">
                            <span class="input-group-addon">
                                <i class="ace-icon fa fa-check"></i>
                            </span>

                            <input type="text" class="form-control search-query" placeholder="输入科室名称">
                            <span class="input-group-btn">
                                <button type="button" class="btn btn-inverse btn-white">
                                    <span class="ace-icon fa fa-search icon-on-right bigger-110"></span>
                                    查找
                                </button>
                            </span>
                        </div>
                        <div class="hr"></div>
                    </div>
                    <div class="col-xs-12 col-sm-8">
                        <p>
                            <button class="btn btn-white btn-info btn-bold" v-on:click="P_AddNewPage">
                                <i class="ace-icon glyphicon glyphicon-plus bigger-120 blue"></i>
                                新增科室
                            </button>
                        </p>
                    </div>
                </div>
                <!--科室列表-->
                <div class="row">
                    <div class="col-xs-12">
                        <table id="simple-table" class="table  table-bordered table-hover">
                            <thead>
                                <tr>

                                    <th>科室名称</th>
                                    <th>包含职务</th>
                                    <th></th>
                                </tr>
                            </thead>

                            <tbody>
                                <tr v-for="item in keshilist">

                                    <td>{{item.ksmc}}</td>
                                    <td>
                                        {{item.ZhiWustr}}
                                    </td>
                                    <td>
                                        <div class="btn-group">
                                            <button data-toggle="dropdown" class="btn btn-primary btn-white dropdown-toggle btn-sm " aria-expanded="true">
                                                操作
                                                <i class="ace-icon fa fa-angle-down icon-on-right"></i>
                                            </button>

                                            <ul class="dropdown-menu">
                                                <li>
                                                    <a href="javascript:void(0)" v-on:click="p_EditData(item)">编辑</a>
                                                </li>

                                                <li>
                                                    <a href="javascript:void(0)" v-on:click="p_DelData(item.ksid)">删除</a>
                                                </li>

                                                <li class="divider"></li>

                                                <li>
                                                    <a href="javascript:void(0)" v-on:click="p_reloadtree(item)">职务管理</a>
                                                </li>
                                            </ul>
                                        </div>
                                    </td>
                                </tr>

                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>

        <!--职务列表-->
        <div class="row" id="zhiweidiv" style="display: none">
            <div class="col-xs-12">
                <h3>{{keshiinfo.ksmc}}</h3>
                <hr />
                <div class="row">
                    <div class="col-xs-6">
                        <div class="widget-box widget-color-blue2">
                            <div class="widget-header">
                                <h4 class="widget-title lighter smaller">职务列表</h4>
                                <div class="widget-toolbar">
                                    <div class="widget-menu">
                                        <a href="#" data-action="settings" data-toggle="dropdown" aria-expanded="false">
                                            <i class="ace-icon fa fa-bars"></i>
                                        </a>

                                        <ul class="dropdown-menu dropdown-menu-right dropdown-light-blue dropdown-caret dropdown-closer">
                                            <li>
                                                <a data-toggle="tab" href="#dropdown1" v-on:click="p_newzhiwu()">新增职务</a>
                                            </li>
                                            <li>
                                                <a data-toggle="tab" href="#dropdown2" v-on:click="p_returnkeshilist()">返回科室列表</a>
                                            </li>
                                        </ul>
                                    </div>

                                </div>
                            </div>

                            <div class="widget-body">
                                <div class="widget-main padding-8">
                                    <ul id="tree1"></ul>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-6">
                        <div class="row">
                            <div class="tabbable tabs-left">
                                <ul class="nav nav-tabs" id="myTab3">
                                    <li class="active">
                                        <a data-toggle="tab" href="#home3">
                                            <i class="pink ace-icon fa fa-tachometer bigger-110"></i>
                                            职务信息
                                        </a>
                                    </li>
                                    <template v-if="zhiwuinfo.zwid!=0">
                                        <li>
                                            <a data-toggle="tab" href="#profile3">
                                                <i class="blue ace-icon fa fa-user bigger-110"></i>
                                                权限配置
                                            </a>
                                        </li>
                                        <li>
                                            <a data-toggle="tab" href="#profile2">
                                                <i class="purple ace-icon fa fa-cutlery bigger-110"></i>
                                                考核表管理
                                            </a>
                                        </li>
                                    </template>
                                </ul>

                                <div class="tab-content">
                                    <div id="home3" class="tab-pane in active">
                                        <div class="col-xs-12 widget-container-col ui-sortable" id="widget-container-col-1">
                                            <!-- #section:custom/widget-box -->
                                            <div class="widget-box ui-sortable-handle" id="widget-box-1">
                                                <div class="widget-header">
                                                    <h5 class="widget-title">职务编区域{{zhiwuinfo.zwid}}</h5>

                                                    <!-- #section:custom/widget-box.toolbar -->
                                                    <!-- /section:custom/widget-box.toolbar -->
                                                </div>

                                                <div class="widget-body">
                                                    <div class="widget-main">
                                                        <div class="row">
                                                            <div class="col-xs-12">
                                                                <form class="form-horizontal" role="form">
                                                                    <div class="form-group">
                                                                        <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 职务 </label>
                                                                        <div class="col-sm-9">
                                                                            <select class="form-control" v-model="zhiwuinfo.zwid">
                                                                                <option value=""></option>
                                                                                <option v-for="option in keshione" v-bind:value="option.zwid">{{option.zwmc}}</option>
                                                                            </select>
                                                                        </div>
                                                                    </div>

                                                                    @*<div class="form-group">
                                                                            <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 工作计划模板{{zhiwuinfo.gzjhid}} </label>
                                                                            <div class="col-sm-9">
                                                                                <select class="form-control" v-model="zhiwuinfo.gzjhid">
                                                                                    <option value="0">未选择</option>
                                                                                    <option v-for="option in kaohelist" v-bind:value="option.mbid"> {{ option.mbmc }}</option>

                                                                                </select>
                                                                            </div>
                                                                        </div>*@

                                                                    <div class="clearfix form-actions">
                                                                        <div class="col-md-offset-1 col-md-11">
                                                                            <button class="btn btn-white btn-info btn-bold" type="button" v-on:click="SaveZhiWu()">
                                                                                <i class="ace-icon fa fa-floppy-o bigger-120 blue"></i>
                                                                                保存
                                                                            </button>

                                                                            <button class="btn btn-white btn-warning btn-bold" type="button" v-on:click="p_DelZhiWu()">
                                                                                <i class="ace-icon fa fa-trash-o bigger-120 orange"></i>
                                                                                删除
                                                                            </button>

                                                                            @*<button class="btn btn-white btn-default btn-round" type="button">
                                                                                    <i class="ace-icon fa fa-times red2"></i>
                                                                                    取消
                                                                                </button>*@
                                                                        </div>
                                                                    </div>
                                                                </form>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>

                                            <!-- /section:custom/widget-box -->
                                        </div>
                                    </div>

                                    <div id="profile3" class="tab-pane">
                                        <div class="row">
                                            <div class="col-xs-12">
                                                <template v-for="item in powertreelist">
                                                    <div class="control-group">
                                                        <label class="control-label bolder blue">{{item.mc}}</label>
                                                        <template v-for="item2 in item.son">
                                                            <div class="checkbox">
                                                                <label class="block">
                                                                    <input name="form-field-checkbox" v-on:change="CheckItem(zhiwuinfo.PowerTrees)" v-model="zhiwuinfo.PowerTrees" v-bind:value="item2.mc" type="checkbox" class="ace input-lg" />
                                                                    <span class="lbl bigger-120"> {{item2.mc}}</span>
                                                                </label>
                                                            </div>
                                                        </template>

                                                    </div>
                                                </template>
                                                <div class="clearfix form-actions">
                                                    <div class="col-md-offset-1 col-md-11">
                                                        <button class="btn btn-white btn-info btn-bold" type="button" v-on:click="savePowerTree()">
                                                            <i class="ace-icon fa fa-floppy-o bigger-120 blue"></i>
                                                            保存
                                                        </button>
                                                    </div>
                                                </div>
                                            </div>


                                        </div>
                                    </div>

                                    <div id="profile2" class="tab-pane">
                                        <div class="row">
                                            <div class="col-xs-12">
                                                <div class="row">
                                                    <div class="col-xs-6">
                                                        <form class="form-horizontal" role="form">
                                                            <div class="input-group input-group-lg">

                                                                <select class="form-control" v-model="zhiwuinfo.gzjhid">
                                                                    <option value="0">未选择</option>
                                                                    <option v-for="option in kaohelist" v-bind:value="option.mbid"> {{ option.mbmc }}</option>
                                                                </select>
                                                                <span class="input-group-btn">
                                                                    <button type="button" class="btn btn-default btn-lg" v-on:click="SaveZhiWuKaoHeBiao()">
                                                                        <span class="ace-icon fa fa-search icon-on-right bigger-110"></span>
                                                                        添加
                                                                    </button>
                                                                </span>
                                                            </div>
                                                        </form>
                                                    </div>
                                                </div>
                                                <hr />
                                                <div class="row">
                                                    <div class="col-xs-12">
                                                        <table id="simple-table" class="table  table-bordered table-hover">
                                                            <thead>
                                                                <tr>
                                                                    <th class="center">
                                                                        考核表名
                                                                    </th>
                                                                    <th>操作</th>

                                                                </tr>
                                                            </thead>

                                                            <tbody>
                                                                <tr v-for="(tr,i) in zhiwukaohebiaos">
                                                                    <td class="center">
                                                                        {{tr.mbmc}}
                                                                    </td>

                                                                    <td class="center">
                                                                        <button class="btn btn-xs btn-danger" v-on:click="DelZhiWuKaoHeBiao(i,tr.mbid)">
                                                                            <i class="ace-icon fa fa-trash-o bigger-120"></i>
                                                                        </button>
                                                                    </td>

                                                                </tr>


                                                            </tbody>
                                                        </table>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>


                            <!-- /.span -->
                        </div>

                    </div>
                </div>

            </div>
        </div>
        <!--弹出框-->
        <div class="row">
            <div class="col-xs-12">
                <div id="dialog-message" class="hide">
                    <div class="row">
                        <div class="col-xs-12">
                            <div class="form-horizontal" role="form">
                                <div class="form-group">
                                    <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 科室名称 </label>
                                    <div class="col-sm-9"><input type="text" placeholder="科室名称" class="col-xs-10 col-sm-5" v-model="keshiinfo.ksmc" /></div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div><!-- #dialog-message -->
            </div>
        </div>
    </div><!-- /.span -->
</div><!-- /.row -->
<script src="~/Scripts/JsModel/Model_KeShi.js"></script>
<script type="text/javascript">

    var MoBan = {
        mbid: 0,
        mbmc: ""
    }
    var PowerTree = {
        mc: "",
        son:[]
    }
    var PowerTreeSon = {
        mc:""
    }
    var ZhiWutree = {
        "father": {
            text: "主任",
            id: 1,
            type: "folder",
            additionalParameters: {
                "children": {
                    员工: { text: "员工", id: 2, type: "item", PowerTrees: [] }
                }
            },
            PowerTrees:[]
        }
    }
    var vm = new Vue(
        {
            el: "#app",
            data: {
                keshilist: [],
                keshiinfo:new  KeShi(),
                zhiwulist: ZhiWutree,
                zhiwuinfo: ZhiWu,
                kaoheinfo: MoBan,
                kaohelist: [],//绑定下拉菜单
                keshione: [],
                jxlist: [],
                testcheck: [],
                powertreelist: [],
                zhiwukaohebiaos:[]
            },
            filter() {

            },
            mounted() {
                this.GetAllKeShi();
                this.p_LoadZhiWu();
                //this.GetGongZuoJiHua();
                //console.log(this.zhiwulist);
                this.initZhiWu(); //kaoheinfo = this.kaohelist[0];
            },
            methods: {
                initZhiWu: function () {
                    var _self = this;
                    //获取工作计划
                    axios.get("@Url.Action("GetGongZuoJiHuo", "KeShiConfig")").then((response) => {
                        _self.kaohelist = [];
                            for (var i = 0; i < response.data.length; i++) {
                                _self.kaohelist.push(response.data[i]);
                            }
                        },
                        (response) => {

                        }
                    ).catch(function(response) {
                        console.log(response);
                        });
                    @*//获取绩效考核
                    axios.get("@Url.Action("GetJiXiaoList", "KeShiConfig")").then((response) => {
                        _self.jxlist = [];
                            for (var i = 0; i < response.data.length; i++) {
                                _self.jxlist.push(response.data[i]);
                            }
                        },
                        (response) => {

                        }
                    ).catch(function(response) {
                        console.log(response);
                        });*@

                    _self.getPowerTree();
                   },
                getPowerTree: function () {
                    var _self = this;
                    axios.get("@Url.Action("GetQuanXian", "KeShiConfig")").then((response) => {
                        _self.powertreelist = [];
                            for (var i = 0; i < response.data.length; i++) {
                                _self.powertreelist.push(response.data[i]);
                            }
                        },
                        (response) => {

                        }
                    ).catch(function(response) {
                        console.log(response);
                    });
                },
                savePowerTree: function() {
                    var _self = this;
                    var readyData={
                        zwid: _self.zhiwuinfo.zwid,
                        ptmc: _self.zhiwuinfo.PowerTrees.join("|"),
                        ksid:_self.keshiinfo.ksid
                    }
                    axios.post("@Url.Action("UpdateZhiWuPowerTrees", "KeShiConfig")", readyData).then((response) => {
                        bootbox.alert("成功", function() {
                            _self.p_reloadtree(_self.keshiinfo);
                        });
                        },
                        (response) => {

                        }
                    ).catch(function(response) {
                        console.log(response);
                    });
                },
                //getCouponSelected: function() {
                //    var _self = this;
                //    _self.zhiwuinfo.gzjhid = _self.kaoheinfo.id;
                //},
                SaveZhiWu:function() {//保存职务
                    var _self = this;
                    var readyData={
                        ksid: _self.keshiinfo.ksid,
                        zwid: _self.zhiwuinfo.zwid
                        //zwmc: _self.zhiwuinfo.zwmc,
                        //pid: _self.zhiwuinfo.pid,
                        //gzjhid: _self.zhiwuinfo.gzjhid,
                        //jxkhid:_self.zhiwuinfo.jxkhid
                    }
                    axios.post("@Url.Action("SaveZhiWu", "KeShiConfig")", readyData).then((response) => {
                            bootbox.alert("成功", function() {
                                _self.p_reloadtree(_self.keshiinfo);
                                _self.zhiwuinfo.zwmc ="";
                                _self.zhiwuinfo.zwid = 0;
                                _self.zhiwuinfo.gzjhid = 0;
                                _self.zhiwuinfo.jxkhid = 0;
                                _self.zhiwuinfo.pid = 0;
                            });
                        },
                        (response) => {

                        }
                    ).catch(function(response) {
                        console.log(response);
                    });
                },
                p_newzhiwu: function () {
                    var _self = this;
                    _self.zhiwuinfo.zwmc ="";
                    _self.zhiwuinfo.zwid = 0;
                    _self.zhiwuinfo.gzjhid = 0;
                    _self.zhiwuinfo.jxkhid = 0;
                    _self.zhiwuinfo.pid = 0;
                    bootbox.alert("可以开始添加新的职务了");
                },
                //GetGongZuoJiHua: function() {
                //    var _self = this;
                //    _self.kaohelist = [];
                //    _self.kaohelist.push({id:1,text:"工作计划1"});
                //    _self.kaohelist.push({ id: 2, text: "工作计划2" });

                //},
                GetAllKeShi: function() { //获取全部科室
                    var _self = this;
                    $.showloading();
                    axios.get("@Url.Action("GetAllKeShi", "KeShiConfig")").then((response) => {
                            _self.keshilist = [];
                            for (var i = 0; i < response.data.length; i++) {
                                _self.keshilist.push(new KeShi(response.data[i]));
                        }
                        $.closeloading();
                        },
                        (response) => {

                        }
                    ).catch(function (response) {
                        $.closeloading();
                        console.log(response);
                    });
                },

                p_DelZhiWu: function() {
                    var _self = this;
                    bootbox.confirm("你确定这个操作吗?",
                        function(result) {
                            if (result) {
                                axios.get('@Url.Action("DelZhiWu", "KeShiConfig")', { params: { ksid: _self.keshiinfo.ksid,zwid: _self.zhiwuinfo.zwid } }).then(
                            function (response) {
                                bootbox.alert("成功", function() {
                                    _self.p_reloadtree(_self.keshiinfo);
                                    _self.zhiwuinfo.zwmc ="";
                                    _self.zhiwuinfo.zwid = 0;
                                    _self.zhiwuinfo.gzjhid = 0;
                                    _self.zhiwuinfo.jxkhid = 0;
                                    _self.zhiwuinfo.pid = 0;
                                });
                            },
                            function(response) {
                                alert(response.status);
                            }
                        )
                        .catch(
                            function(error) {
                                alert(error);
                            }
                        );
                            }
                        });

                },
                P_AddNewPage: function (e) {//弹出新增科室窗口
                    var _self = this;
                    e.preventDefault();
                    var dialog = dialog_comm(true,"dialog-message", "新增科室信息", null, function () { _self.P_SaveKeShi(); },true);
                },
                P_SaveKeShi: function () {//保存科室
                    var _self = this;
                    var readyData={
                        ksid: _self.keshiinfo.ksid,
                        ksmc: _self.keshiinfo.ksmc
                    }
                    axios.post('@Url.Action("SaveKeShi", "KeShiConfig")', readyData).then(
                            function(response) {
                                bootbox.alert("成功", function() {
                                     _self.GetAllKeShi();
                                });
                                //vm.goodsList.splice(response.data.length);
                            },
                            function(response) {
                                //alert(response.status);
                            }
                        )
                        .catch(
                            function(error) {
                                //alert(error);
                            }
                        );
                },
                p_EditData: function(obj) {//编辑科室

                    var _self = this;
                    _self.keshiinfo = obj;
                    var dialog = dialog_comm(true,"dialog-message",
                        "编辑科室信息",
                        null,
                        function() { _self.P_SaveKeShi(); },
                        true);
                },
                p_DelData: function (id) {//删除科室
                    var _self = this;
                    if (id && id > 0) {
                        bootbox.confirm("你确定这个操作吗?",
                            function(result) {
                                if (result) {
                                    axios.get('@Url.Action("DelKeShi", "KeShiConfig")', { params: { ksid: id }}).then(
                                            function(response) {
                                                bootbox.alert("成功", function () { _self.GetAllKeShi(); });
                                                //vm.goodsList.splice(response.data.length);
                                            },
                                            function(response) {
                                                bootbox.alert(response.status);
                                                //alert(response.status);
                                            }
                                        )
                                        .catch(
                                            function(error) {
                                                //alert(error);
                                            }
                                        );
                                }
                            });
                    } else {
                        //bootbox.alert("id=" + id);
                    }
                },
                p_reloadtree: function (obj) {//展开部门内的职务
                    $("#keshidiv").hide($("#zhiweidiv").show());
                    var _self = this;
                    _self.zhiwulist = [];
                    _self.zhiwuinfo.ksid = obj.ksid;
                    _self.keshiinfo = obj;
                    //获取一级职务
                    axios.get("@Url.Action("GetKeShiZhiWuOne", "KeShiConfig")", { params: { ksid: _self.keshiinfo.ksid  } }).then((response) => {
                            _self.keshione = [];
                            for (var i = 0; i < response.data.length; i++) {
                                _self.keshione.push(response.data[i]);
                            }
                        },
                        (response) => {

                        }
                    ).catch(function(response) {
                        console.log(response);
                    });

                    axios.get('@Url.Action("GetKeShiZhiWu", "KeShiConfig")', { params: { keshiid: _self.keshiinfo.ksid }}).then(
                        function (response) {
                            _self.zhiwulist=response.data;
                                //bootbox.alert("成功");
                                //vm.goodsList.splice(response.data.length);
                            var sampleData = _self.initiateData();//see below
                    $('#tree1').find("li:not([data-template])").remove();
                    $('#tree1').ace_tree({
                        dataSource: sampleData,
                        loadingHTML:
                            '<div class="tree-loading"><i class="ace-icon fa fa-refresh fa-spin blue"></i></div>',
                        'open-icon': 'ace-icon fa fa-folder-open',
                        'close-icon': 'ace-icon fa fa-folder',
                        'itemSelect': true,
                        'folderSelect': true,
                        'multiSelect': false,
                        'selected-icon': null,
                        'unselected-icon': null,
                        'folder-open-icon': 'ace-icon tree-plus',
                        'folder-close-icon': 'ace-icon tree-minus'
                    });
                            $('#tree1').tree('render');
                        },
                        function (response) {
                            bootbox.alert(response.status);
                            //alert(response.status);
                        }
                    )
                        .catch(
                            function (error) {
                                //alert(error);
                            }
                        );
                },
                p_LoadZhiWu: function () {//目录树初始化
                    var _self = this;
                    var sampleData = this.initiateData();//see below
                    $('#tree1').ace_tree({
                        dataSource: sampleData,
                        loadingHTML:
                            '<div class="tree-loading"><i class="ace-icon fa fa-refresh fa-spin blue"></i></div>',
                        'open-icon': 'ace-icon fa fa-folder-open',
                        'close-icon': 'ace-icon fa fa-folder',
                        'itemSelect': true,
                        'folderSelect': true,
                        'multiSelect': false,
                        'selected-icon': null,
                        'unselected-icon': null,
                        'folder-open-icon': 'ace-icon tree-plus',
                        'folder-close-icon': 'ace-icon tree-minus'
                    }).on('selected.fu.tree',
                        function(e, data) {
                            _self.zhiwuinfo.zwmc = data.selected[0].text;
                            _self.zhiwuinfo.zwid = data.selected[0].id;
                            _self.zhiwuinfo.gzjhid = data.selected[0].gzjhid;
                            _self.zhiwuinfo.jxkhid = data.selected[0].jxkhid;
                            _self.zhiwuinfo.pid = data.selected[0].pid;
                            _self.zhiwuinfo.PowerTrees = data.selected[0].PowerTrees;
                            _self.GetZhiWuKaoHeBiaos(_self.zhiwuinfo.zwid);
                        });
                },
                GetZhiWuKaoHeBiaos: function(zwid) {
                    var _self = this;
                    var readyData={
                        ksid: _self.keshiinfo.ksid,
                        zwid: zwid
                    }
                    axios.post('@Url.Action("GetZhiWuKaoHeBiaos", "KeShiConfig")', readyData).then(
                            function(response) {
                            _self.zhiwukaohebiaos = [];
                            for (var i = 0; i < response.data.length; i++) {
                                _self.zhiwukaohebiaos.push(response.data[i]);
                            }
                            },
                            function(response) {
                                //alert(response.status);
                            }
                        )
                        .catch(
                            function(error) {
                                //alert(error);
                            }
                        );
                },
                DelZhiWuKaoHeBiao: function(i,mbid) {
                    var _self = this;
                    var readyData={
                        ksid: _self.keshiinfo.ksid,
                        zwid: _self.zhiwuinfo.zwid, khbid: mbid
                    }
                    axios.post('@Url.Action("DelZhiWuKaoHeBiao", "KeShiConfig")', readyData).then(
                            function(response) {
                                bootbox.alert("成功", function () { _self.zhiwukaohebiaos.splice(i,1); });
                            },
                            function(response) {
                                //alert(response.status);
                            }
                        )
                        .catch(
                            function(error) {
                                //alert(error);
                            }
                        );
                },
                SaveZhiWuKaoHeBiao: function() {
                    var _self = this;
                    var readyData={
                        ksid: _self.keshiinfo.ksid,
                        zwid: _self.zhiwuinfo.zwid, khbid: _self.zhiwuinfo.gzjhid
                    }
                    axios.post('@Url.Action("SaveZhiWuKaoHeBiao", "KeShiConfig")', readyData).then(
                            function(response) {
                            bootbox.alert("成功", function () { _self.GetZhiWuKaoHeBiaos(_self.zhiwuinfo.zwid); });
                            },
                            function(response) {
                                //alert(response.status);
                            }
                        )
                        .catch(
                            function(error) {
                                //alert(error);
                            }
                        );
                },
                selectdata: function () {
                    var output = '' ;
                    var items = $('#tree1').tree('selectedItems' );
                    for (var i in items) {
                        if (items.hasOwnProperty(i)) {
                        var item = items[i];
                        output += item.id + ":"+ item.text+"\n" ;
                        }
                    }
                    alert(output);
                },
                initiateData:function() {//序列化目录树格式
                    var _self = this;
                    var dataSource1 = function (options, callback) {
                        var $data = null;
                        if (!("text" in options) && !("type" in options)) {
                            $data = _self.zhiwulist;//the root tree
                            callback({ data: $data });
                            return;
                        }
                        else if ("type" in options && options.type == "folder") {
                            if ("additionalParameters" in options && "children" in options.additionalParameters)
                                $data = options.additionalParameters.children || {};
                            else $data = {}//no data
                        }

                        if ($data != null)//this setTimeout is only for mimicking some random delay
                            setTimeout(function () { callback({ data: $data }); }, parseInt(Math.random() * 500) + 200);
                    }
                    return dataSource1;
                },
                p_returnkeshilist: function() {//从职务界面返回科室列表
                    $("#zhiweidiv").hide($("#keshidiv").show());
                },
                CheckItem: function (obj) {
                    //debugger;
                    console.log(obj);
                    //var _self = this;
                    //bootbox.alert(_self.testcheck);
                }
            },
            watch : {
                keshilist:function(val) {
                    //debugger;
                }
            }
        });
</script>